#include "stdafx.h"
#include "AccountItem.h"

AccountItem::AccountItem(QWidget *parent)
	: QWidget(parent)
{
	accountLabel = new QLabel();
	deleteButton = new QPushButton();

	QPixmap pixmap(":/Resources/delete.png");
	deleteButton->setIcon(pixmap);
	deleteButton->setIconSize(pixmap.size());
	deleteButton->setStyleSheet("background: transparent;");
	deleteButton->setMinimumSize(QSize(16, 16));
	deleteButton->setMaximumSize(QSize(16, 16));
	connect(deleteButton, SIGNAL(clicked()), this, SLOT(removeAccount()));

	QHBoxLayout *mainLayout = new QHBoxLayout();
	mainLayout->addWidget(accountLabel);
	mainLayout->addStretch();
	mainLayout->addWidget(deleteButton);
	mainLayout->setContentsMargins(5, 5, 5, 5);
	mainLayout->setSpacing(5);
	this->setLayout(mainLayout);
}

AccountItem::~AccountItem()
{

}

void AccountItem::setAccountNumber(QString account_text)
{
	accountLabel->setText(account_text);
}

QString AccountItem::getAccountNumber()
{
	return accountLabel->text();
}

void AccountItem::removeAccount()
{
	emit removeAccount(this);
}
